package com.no1.zy.controller.stu;

import com.no1.zy.pojo.Student;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;

@RequestMapping("/stu")
@Controller
@Slf4j
public class StuController {

    @RequestMapping("iteList")
    public String iteratorList(Model model) {
        List<Student> stuList = new ArrayList<>();
//        stuList.add(new Student(1001, "赵一", "男", null, 21));
//        stuList.add(new Student(1001, "钱二", "女", null, 22));
//        stuList.add(new Student(1001, "孙三", "男", null, 23));
//        stuList.add(new Student(1001, "李四", "女", null, 24));
        Calendar cal = new GregorianCalendar();
        cal.set(2001, 3, 16);
//        Student stu1 = new Student(1005, "周五", "男", cal.getTime(), 20);
//        Student stu2 = new Student(1006, "吴六", "女", Date.from(LocalDateTime.of(2006,6,28,23,30,33).atZone(ZoneId.systemDefault()).toInstant()),26);

//       stuList.add(stu1);
//       stuList.add(stu2);
        model.addAttribute("stuList", stuList);
        return "stu/show";

    }

    @RequestMapping("iteMap")
    public String iteratorMap(Model model){
        Map<String ,Student> stuMap = new HashMap<>();
//        stuMap.put("s1",new Student(1001, "赵一", "男", null, 21));
//        stuMap.put("s2",new Student(1001, "钱二", "女", null, 20));
//        stuMap.put("s3",new Student(1001, "孙三", "男", null, 22));
        model.addAttribute("stuMap",stuMap);
        return "stu/show2";

    }
}
